﻿/*
    Autor : Roger Medeiros
    Data  : 01/02/2012
    Site  : www.interacaosistemas.com.br
*/

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using i9PgAdmin.Core;

namespace i9PgAdmin
{
    public partial class FrmAgenda : Form
    {
        private Agenda agenda = null;
        public FrmAgenda()
        {
            InitializeComponent();
        }

        private void imgSair_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void pictureBox1_Click(object sender, EventArgs e)
        {
            agenda.Caminho = this.txtdirdestino.Text.Trim();
            agenda.Horas = this.txthora.Text;
            agenda.Minutos = this.txtMinutos.Text;
            agenda.Segunda = this.d1.Checked;
            agenda.Terca = this.d2.Checked;
            agenda.Quarta = this.d3.Checked;
            agenda.Quinta = this.d4.Checked;
            agenda.Sexta = this.d5.Checked;
            agenda.Sabado = this.d6.Checked;
            agenda.Domingo = this.d7.Checked;
            agenda.Zipar = this.chkComprimir.Checked;
            this.agenda.Salva();

            this.Close();
        }

        private void FrmAgenda_Load(object sender, EventArgs e)
        {
            agenda = new Agenda();
            agenda.Carrega();

            this.txtdirdestino.Text = agenda.Caminho;
            this.txthora.Text = agenda.Horas;
            this.txtMinutos.Text = agenda.Minutos;
            this.d1.Checked = agenda.Segunda;
            this.d2.Checked = agenda.Terca;
            this.d3.Checked = agenda.Quarta;
            this.d4.Checked = agenda.Quinta;
            this.d5.Checked = agenda.Sexta;
            this.d6.Checked = agenda.Sabado;
            this.d7.Checked = agenda.Domingo;
            this.chkComprimir.Checked = agenda.Zipar;
        }

        private void txthora_Validated(object sender, EventArgs e)
        {
            txthora.Text = txthora.Text.PadLeft(2, '0');
        }

        private void txtMinutos_Validated(object sender, EventArgs e)
        {
            txtMinutos.Text = txtMinutos.Text.PadLeft(2, '0');
        }

        private void txtdirdestino_MouseDoubleClick(object sender, MouseEventArgs e)
        {
            if (fd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                txtdirdestino.Text = fd.SelectedPath;
        }
    }
}
